# -*- coding: utf-8 -*-
#
# File: CalHoliday.py
#
# Copyright (c) 2008 by []
# Generator: ArchGenXML Version 2.0
#            http://plone.org/products/archgenxml
#
# GNU General Public License (GPL)
#

__author__ = """unknown <unknown>"""
__docformat__ = 'plaintext'

from AccessControl import ClassSecurityInfo
from Products.Archetypes.atapi import *
from zope.interface import implements
import interfaces
from Products.NetsightCal.content.CalShared import CalShared
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.NetsightCal.config import *

##code-section module-header #fill in your manual code here
##/code-section module-header

schema = Schema((

    StringField(
        name='destination',
        widget=StringField._properties['widget'](
            label="Destination",
            label_msgid='NetsightCal_label_destination',
            i18n_domain='NetsightCal',
        ),
    ),
    StringField(
        name='employee',
        widget=StringField._properties['widget'](
            label="Employee",
            label_msgid='NetsightCal_label_employee',
            i18n_domain='NetsightCal',
        ),
        required=1,
    ),
    StringField(
        name='contactno',
        widget=StringField._properties['widget'](
            label="Contact Number",
            label_msgid='NetsightCal_label_contactno',
            i18n_domain='NetsightCal',
        ),
    ),
    BooleanField(
        name='approved',
        widget=BooleanField._properties['widget'](
            label="Approved",
            label_msgid='NetsightCal_label_approved',
            i18n_domain='NetsightCal',
        ),
    ),
    StringField(
        name='title',
        widget=StringField._properties['widget'](
            visible=0,
            label='Title',
            label_msgid='NetsightCal_label_title',
            i18n_domain='NetsightCal',
        ),
    ),
),
)

##code-section after-local-schema #fill in your manual code here
##/code-section after-local-schema

CalHoliday_schema = BaseSchema.copy() + \
    getattr(CalShared, 'schema', Schema(())).copy() + \
    schema.copy()

##code-section after-schema #fill in your manual code here
##/code-section after-schema

class CalHoliday(BaseContent, CalShared, BrowserDefaultMixin):
    """
    """
    security = ClassSecurityInfo()
    implements(interfaces.ICalHoliday)

    meta_type = 'CalHoliday'
    _at_rename_after_creation = True

    schema = CalHoliday_schema

    ##code-section class-header #fill in your manual code here
    ##/code-section class-header

    # Methods

    # Manually created methods

    def Title(self):
        """Define the title as concatenation of name and destination"""
        title = ''
        if self.getEmployee():
            title = self.getEmployee()
        else:
            title = 'Employee'
        if self.getDestination():
            title += ' in ' + self.getDestination()
        elif self.getEmployee():
            title += ' on holiday'
        return title

    def location(self):
        """Define the location as a location attribute"""
        return self.getDestination()



registerType(CalHoliday, PROJECTNAME)
# end of class CalHoliday

##code-section module-footer #fill in your manual code here
##/code-section module-footer



